//
//  ZHReceiver.swift
//  命令设计模式
//
//  Created by slience on 2019/11/18.
//  Copyright © 2019 shehuiren. All rights reserved.
//

import UIKit

public class ZHReceiver: NSObject {

    //被服务对象
    var client : UIView?{
        
        didSet{
            
            let color = client?.backgroundColor!
            
            color?.getHue(&_hud, saturation: &_saturation, brightness: &_brightness, alpha: &_alpha)
            
        }
    }
    
    var _hud : CGFloat = 0.0
    var _saturation : CGFloat = 0.0
    var _brightness : CGFloat = 0.0
    var _alpha : CGFloat = 0.0
    
    //增加频道
    func addNum(num : NSNumber){
        
        //todo
    }
    
    //减少频道
    func delNum(num : NSNumber){
        
        //todo
    }
    
    //变暗
    func makeDarker(par : CGFloat){
        
        _brightness -= par
        
        _brightness = max(0, _brightness)
        
        client?.backgroundColor = UIColor.init(hue: _hud, saturation: _saturation, brightness: _brightness, alpha: _alpha)
        
    }
    //变亮
    func makeLighter(par : CGFloat){
        
        _brightness += par
               
        _brightness = min(1, _brightness)
               
               client?.backgroundColor = UIColor.init(hue: _hud, saturation: _saturation, brightness: _brightness, alpha: _alpha)
    }
    
}
